﻿using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace KamRemakeRemake.GameObjects.UnitObjects.Units {
    /// <summary>
    /// collection of units, used for mass updating and so on
    /// this is only for testing purposes should be changed to a list of tiles
    /// </summary>
    public class UnitList : List<Unit> {
        /// <summary>
        /// Update all the units in the unitlist that have an action
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime) {
            foreach (var unit in this) {
                unit.Update(gameTime);
            }
        }

        /// <summary>
        /// Call the loadcontent method for all the units that have an action
        /// </summary>
        /// <param name="contentManager"></param>
        public void LoadContent(ContentManager contentManager) {
            foreach (var unit in this) {
                unit.LoadContent(contentManager);
            }
        }

        /// <summary>
        /// Call the draw method for all the units that have an action
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="spriteBatch"></param>
        public void Draw(GameTime gameTime, SpriteBatch spriteBatch, ContentManager contentManager) {
            foreach (var unit in this) {
                unit.Draw(gameTime, spriteBatch, contentManager);
            }
        }
    }
}
